/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CODE;


import DATA.handBD;
import java.sql.SQLException;

/**
 *
 * @author Administrator
 */
public class Login {

    handBD conect = new handBD();
    
    public Login() throws SQLException
    {
        conect = new handBD();
    }

  
    public String Logear(String login, String pas) throws SQLException//validar
{
    String rpta;
    rpta = conect.log(login,pas);

    if(rpta.equals("error"))
    {
        return "-1";
    }
    else
    {
        //String tipo = rpta.substring(0, 3);
        //System.out.println(tipo);
        if(rpta.equals("alumno"))
        {
            System.out.println(rpta);
            return "2";
        }
         else if(rpta.equals("operario"))
        { //rpta= "2" + login;
            //System.out.println(rpta+"2");
            return "1";
        }
         else
         {
            return "-1";
         }

        /*boolean resultad =rpta.startsWith("Ad");
        if(resultad == true)
            return "1";
        else
        { //rpta= "2" + login;
            System.out.println(rpta+"2");
            return "2";
        }*/
            //return rpta;
    }
}




}
